import urllib.parse
from automatic.MapDataHelper import MapDataHelper


class DataAnalyzer(object):
    def __init__(self):
        self._map_data_helper = MapDataHelper()

    def response(self, flow):
        link_parse_result = urllib.parse.urlparse(flow.request.url)
        if link_parse_result.netloc == "cat-match.easygame2021.com":
            if "game/map_info_ex" in link_parse_result.path:
                self._map_data_helper.update_map_data(flow.response.content)
            elif "topic/game_start" in link_parse_result.path:
                self._map_data_helper.update_map_data(flow.response.content)


addons = [DataAnalyzer()]
